//
//  WinStarView.cpp
//  FruitCrush
//
//  Created by gaoyu on 15/8/2.
//
//

#include "WinStarView.h"

USING_NS_CC;

#define WIDTH    250
#define HEIGHT   95

#define STARX_PAD    (85)
#define STARY_PAD    (15)


WinStarView::WinStarView()
{
}

WinStarView* WinStarView::create(int num)
{
    WinStarView *pRet = new(std::nothrow) WinStarView();
    if (pRet && pRet->init(num)){
        pRet->autorelease();
        return pRet;
    }
    else
    {
        delete pRet;
        pRet = NULL;
        return NULL;
    }
}

bool WinStarView::init(int num)
{
    if (!Layer::init()) {
        return false;
    }
    starInit(num);
    
    
    return true;
}

void WinStarView::starInit(int num)
{
    auto cache = SpriteFrameCache::getInstance();
    cache->addSpriteFramesWithFile("WinUnit.plist");
    
    if(num >= 1){
        Sprite *star1 = Sprite::createWithSpriteFrameName("WinStar1.png");
        star1->setAnchorPoint(Vec2::ZERO);
        star1->setPosition(Point(0,0));
        this->addChild(star1);
    }
    
    if(num >= 2){
        Sprite *star2 = Sprite::createWithSpriteFrameName("WinStar2.png");
        star2->setAnchorPoint(Vec2::ZERO);
        star2->setPosition(Point(STARX_PAD,STARY_PAD));
        this->addChild(star2);
    }
    
    if(num >= 3){
        Sprite *star3 = Sprite::createWithSpriteFrameName("WinStar3.png");
        star3->setAnchorPoint(Vec2::ZERO);
        star3->setPosition(Point(STARX_PAD*2,0));
        this->addChild(star3);
    }
    
}

Size WinStarView::getMySize()
{
    return Size(WIDTH,HEIGHT);
}
